home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 2000 November: Tool Chest / Dev.CD Nov 00 TC Disk 2.toast / pc / sample code / overview / dtscpluslibrary / headers / memoryclass.h < prev    next >
Encoding:
Text File  |  2000-09-28  |  3.2 KB  |  107 lines

  1. /*
  2.     File:        MemoryClass.h
  3.  
  4.     Contains:    TMemory is a simple object checks heap and stack values, as well as changes them.
  5.                   TMemoryClass.h contains the TMemory class definitions. 
  6.  
  7.     Written by: Kent Sandvik    
  8.  
  9.     Copyright:    Copyright © 1999 by Apple Computer, Inc., All Rights Reserved.
  10.  
  11.                 You may incorporate this Apple sample source code into your program(s) without
  12.                 restriction. This Apple sample source code has been provided "AS IS" and the
  13.                 responsibility for its operation is yours. You are not permitted to redistribute
  14.                 this Apple sample source code as "Apple sample source code" after having made
  15.                 changes. If you're going to re-distribute the source, we require that you make
  16.                 it clear in the source that the code was descended from Apple sample source
  17.                 code, but that you've made changes.
  18.  
  19.     Change History (most recent first):
  20.                 8/18/1999    Karl Groethe    Updated for Metrowerks Codewarror Pro 2.1
  21.                 
  22.  
  23. */
  24. // Declare label for this header file
  25. #ifndef _MEMORYCLASS_
  26. #define _MEMORYCLASS_
  27.  
  28. #ifndef _DTSCPLUSLIBRARY_
  29. #include "DTSCPlusLibrary.h"
  30. #endif
  31.  
  32. // TOOLBOX INCLUDES
  33. #ifndef __MEMORY__
  34. #include <Memory.h>
  35. #endif
  36.  
  37. #ifndef __RESOURCES__
  38. #include <Resources.h>
  39. #endif
  40.  
  41. #ifndef __TYPES__
  42. #include <Types.h>
  43. #endif
  44.  
  45. // GLOBAL DEFINITIONS
  46. const OSType kStackResource = 'stak';            // definition of our resource for defining stack size
  47.  
  48.  
  49. // _________________________________________________________________________________________________________ //
  50. //    TMemory Class Interface.
  51. class TMemory
  52. // TMemory is a simple memory utility class that keeps track of size of the stack and heap, and could
  53. // be used to manipulate the memory sizes.
  54. {
  55. public:
  56.     // TYPEDEFS AND ENUMS
  57.     enum EConstants                                // constants used in the TMemory class
  58.     {
  59.         kNoMinHeap = 0, kNoMinStack = 0
  60.     };
  61.  
  62.     // CONSTRUCTORS AND DESTRUCTORS
  63.     TMemory(const long minHeap = kNoMinHeap,
  64.             // default constructor
  65.             // default constructor
  66.             const long minStack = kNoMinStack);
  67.     virtual~ TMemory();                            // default destructor
  68.  
  69.     // MAIN INTERFACE
  70.     virtual long GetStackSize();                // get size of stack
  71.     virtual Boolean SetStackSize(const long stackValue);// set new stack size
  72.     virtual Boolean SetStackSizeFromResources();// set stack sizes based on resource information
  73.     virtual Boolean IncreaseStackSize(const long stackValue);// increase the current stack size
  74.     virtual Boolean CheckStackSize();            // check if selected min stack size is OK
  75.     virtual Boolean CheckHeapSize();            // check if selected min heap size is OK
  76.  
  77.     virtual long GetHeapSize();                    // get size of heap
  78.  
  79.     // FIELDS
  80. protected:
  81.     long fMinHeap;                                // minimum heap size
  82.     long fMinStack;                                // minimum stack size
  83.     OSErr fError;                                // latest error
  84.  
  85.     // PRIVATE STRUCTURES
  86. private:
  87.     struct StackResource                        // for the kStackResource resource mapping
  88.     {
  89.         long stackVal;                            // the new stack size
  90.     };
  91.  
  92.  
  93.     typedef StackResource* StackValuePtr;        // typecasted for handy re-use
  94.     typedef StackResource** StackValueHandle;
  95. };
  96.  
  97.  
  98. #endif
  99.  
  100. // _________________________________________________________________________________________________________ //
  101.  
  102. /*    Change History (most recent last):
  103.   No        Init.    Date        Comment
  104.   1            khs        1/2/93        New file
  105.   2            khs        1/3/93        Cleanup
  106. */
  107.